﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MachiningHelper.ToolFile
{
    class CRN
    {
        public static string Changecrn(Content Custstr, bool IsPMOD2)
        {
            if (IsPMOD2)
            {
                if (Custstr.Body.Contains("1"))
                    Custstr.Body = Custstr.Body.Replace("1", "4");
                else if (Custstr.Body.Contains("4"))
                    Custstr.Body = Custstr.Body.Replace("4", "1");
            }
            else
            {
                if (Custstr.Body.Contains("1"))
                    Custstr.Body = Custstr.Body.Replace("1", "3");
                else if (Custstr.Body.Contains("4"))
                    Custstr.Body = Custstr.Body.Replace("4", "2");
            }
            return Custstr.Body;
        }
        public static void ChangeCRN(List<Content> custr, bool IsPMOD2)
        {
            for (int i = 0; i < custr.Count; i++)
            {
                if (custr[i].Body != null)
                {
                    if (custr[i].Body.Contains("NAME=CRN"))
                        Changecrn(custr[i], IsPMOD2);
                }
            }
        }
        public static string changeSide(Content custstr, string a, string side)
        {
            string s = custstr.Body;
            custstr.Body = s.Replace(a, side);
            return custstr.Body;
        }
        public static void ChangeSide(List<Content> custr)
        {
            for (int i = 0; i < custr.Count; i++)
            {
                if (custr[i].Body != null)
                {
                    if (custr[i].Body.Contains("NAME=SIDE,VALUE=0"))
                        changeSide(custr[i], "0", "5");
                }
            }
        }
        public static string doubleThickness(Content c,string thickness,string thickness2)
        {
            c.Body = c.Body.Replace(thickness, thickness2);
            return c.Body;
        }
    }
}
